package com.zjb.demo.framework.security;

import com.zjb.demo.common.domain.LoginUser;

/**
 * @author 庄佳彬
 * @since 2023/12/25 20:47
 */
public class AuthenticationContextHolder {
    private static final ThreadLocal<LoginUser> contextHolder = new ThreadLocal<>();

    /**
     * 获取认证信息
     *
     * @return 返回认证信息
     */
    public static LoginUser getAuthentication() {
        return contextHolder.get();
    }


    /**
     * 设置认证信息
     *
     * @param authentication 认证信息对象
     */
    public static void setAuthentication(LoginUser authentication) {
        contextHolder.set(authentication);
    }


    /**
     * 清除身份验证信息
     */
    public static void clearAuthentication() {
        contextHolder.remove();
    }

}

